Skip to content

Emit catalog events from workflow code - #105

Merged
duynhne merged 2 commits into
mainfrom
feat/temporalx-workflow-event
Sep 24, 2026
Merged

duynhne merged 2 commits into
mainfrom
feat/temporalx-workflow-event

Conversation

@duynhne

@duynhne duynhne commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Adds temporalx.WorkflowEvent(ctx workflow.Context, level, name, msg, attrs...) for catalog events decided in workflow code (order's saga outcome, compensation steps, exhausted retries), where only the SDK's replay-aware logger may run.

  • Writes via workflow.GetLogger → replay writes nothing; live run writes once. Test: live=1 / replay=0 with a run counter proving replay executed the code.
  • Same grammar handling as the facade (event.invalid, .conflict rename).
  • Docs: MIGRATION-slogx lifecycle section; slogx Event carve-out comment extended.

Gate: make test-temporalx 96.0%, lint 0 issues.

🤖 Generated with Claude Code

https://claude.ai/code/session_018N7ME8TyWS33cbpWV3v8E8

Most of order's catalog events are decided in workflow code: the saga's
failed/compensated outcome, each compensation step, a completion or
inventory commit that exhausted its retries. Only the SDK's
replay-aware logger may run there, and the facade may not.

temporalx.WorkflowEvent writes through workflow.GetLogger, so a
replayed history writes nothing; a live run writes the event once, and
the replay test proves the code ran. It applies the facade's grammar:
an invalid name goes under event.invalid and a caller's own event
attribute is renamed.
An invalid event name is now cut the way the facade cuts it: invalid
UTF-8 repaired, the cut on a rune boundary, and a truncation marker, so
event.invalid reads the same on both paths. The SDK logger skips one
more frame, so the record's source is the workflow line that called
WorkflowEvent rather than temporalx. The doc states when replay safety
holds and how non-standard levels map; the grammar tests pin exact
values, including the 64-byte edge and a cut inside a rune.
@sonarqubecloud

Copy link
Copy Markdown

@duynhne
duynhne merged commit a025f9b into main Sep 24, 2026
11 checks passed
@duynhne
duynhne deleted the feat/temporalx-workflow-event branch September 24, 2026 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant